package control;
/**
 * @author 
 *RequestParameter This class is used to get the the request in perticular format return the text before special character  
 */
public class RequestParameter
{
	private String version = "11";
	private String request;
	private String password;
	private String process;
	private String message;
	private String username;
	private String productName = "pool";
	private String keyword="";
	private boolean Event = true;
	
	/**
	 *  SplitRequest() This method is used to spilit the string from # special character
	 * @param parseMessage
	 * @return message String
	 */
	public String splitRequest(String parseMessage)
	{
		SpecialCharacter spChar = new SpecialCharacter();
		int start = spChar.getNextSpChar(0, parseMessage.toCharArray());
		String usernameMessage= parseMessage.substring(0,start);
		
		String requestArray[]= usernameMessage.split(" ");
	
		//updated during view function for the condition  if there is no spchar after  usernameMessage e.g. 11 property_details view mid
		//then the length of the  versionRequest[] becomes greater than three.
		
		if(requestArray.length>3)
		{
			return "ERROR : Request Parametersnot found.";
		}
		version = requestArray[0];
		request= requestArray[1];
		process = requestArray[2];
		
		int end = parseMessage.indexOf('#');
		if(end == -1)
			return "ERROR : Password not found";
		password = parseMessage.substring(end+1);
						
		parseMessage=parseMessage.substring(start, end);
		message = parseMessage;
		return parseMessage;
	}
	/**
	 *setUsername() this method is used to set the userrname
	 * @param username gets the username
	 */
	public void setUsername(String username)
	{
		this.username = username;
	}
	/**
	 *setKeyword() this method is used to set the keyword
	 * @param username gets the keyword
	 */
	public void setKeyword(String Keyword)
	{
		this.keyword = Keyword;
	}
	public void setProductName(String productName) 
	{
		this.productName = productName;
	}
	
	public String getProductName() 
	{
		return productName;
	}
	
	/**
	 *getUsername() this method is used to get the userrname
	 */
	public String getUsername()
	{
		return username;
	}
	/**
	 *setVersion() this method is used return the the value of request nad set the request
	 */
	public void setVersion(String version)
	{
		this.version = version;
	}
	/**
	 *getVersion() this method is used return the the value of version
	 */
	public String getVersion()
	{
		return version;
	}
	
	public void setRequest(String request) 
	{
		this.request = request;
	}
	
	public String getRequest()
	{
		return request;
	}
	
	public void setProcess(String process) {
		this.process = process;
	}
	/**
	 *getProcess() this method is used return the the value of process
	 */
	public String getProcess()
	{
		return process;
	}
	public String getKeyword()
	{
		return keyword;
	}
	
	public void setPassword(String password) 
	{
		this.password = password;
	}
	/**
	 *getPassword() this method is used return the password
	 */ 
	public String getPassword()
	{
		return password;
	}
	/**
	 * setMesssage() This method is used to set the message
	 * @param message
	 */
	public void setMessage(String message) 
	{
		this.message = message;
	}
	/**
	 *getMessage() this method is used return the the value of message
	 */
	public String getMessage()
	{
		return message;
	}
	
	public void setEvent(boolean event) {
		Event = event;
	}
	public boolean getEvent() 
	{
		return Event;
	}
	public static void main(String[] args) 
	{
		//String msg="11 property_details  add";
		//String msg="1111*1111# is# oscpro*444 #555 55#* Wuikiocaenvvvvv";
		String msg="11 property_details add*retailervalidation|type#Storage";
		RequestParameter rp=new RequestParameter();
		System.out.println("Output is="+rp.splitRequest(msg));
		
	}


}
